package com.OnTimeTeam.OnTime;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class SnoozeOptionsAdapter  extends ArrayAdapter<String> {

	private ArrayList<String> items; //all alarms details

	///////////////
	//CTOR - init' the array of AlarmFeatures and ApplicationContext object
	public SnoozeOptionsAdapter(Context context, int textViewResourceId, ArrayList<String> items) {
		super(context, textViewResourceId, items);
		this.items = items;
	}

	////////////////////
	//This method sets the view of ONE item in the list (it gets it's index - it's the same index as the AlarmFeatures ArrayList)
	public View getView(final int index, View convertView, ViewGroup parent) {
	
		View view = convertView;
		LayoutInflater inflater = null;
		
		if (view == null) {
			inflater = (LayoutInflater)this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = inflater.inflate(R.layout.snooze_options_list, null);//set the view
		}
		
		TextView entry = (TextView)view.findViewById(R.id.entry);
		TextView about = (TextView)view.findViewById(R.id.about); 

		entry.setFocusable(false);
		about.setFocusable(false);
		
		switch(index){
		
			case 0:
				entry.setText(getContext().getResources().getString(R.string.interval));
				
				if(items.get(0).equals("3"))
					about.setText(getContext().getResources().getString(R.string.fireEvery3Minutes));
				else if(items.get(0).equals("5"))
					about.setText(getContext().getResources().getString(R.string.fireEvery5Minutes));				
				else if(items.get(0).equals("10"))
					about.setText(getContext().getResources().getString(R.string.fireEvery10Minutes));				
				else if(items.get(0).equals("15"))
					about.setText(getContext().getResources().getString(R.string.fireEvery15Minutes));
				else if(items.get(0).equals("20"))
					about.setText(getContext().getResources().getString(R.string.fireEvery20Minutes));				
				else if(items.get(0).equals("30"))
					about.setText(getContext().getResources().getString(R.string.fireEvery30Minutes));				
				
				break;
			case 1:
				entry.setText(getContext().getResources().getString(R.string.repeatition));
				
				if(items.get(1).equals("3"))
					about.setText(getContext().getResources().getString(R.string.repeat3Times));
				else if(items.get(1).equals("4"))
					about.setText(getContext().getResources().getString(R.string.repeat4Times));
				else if(items.get(1).equals("5"))
					about.setText(getContext().getResources().getString(R.string.repeat5Times));
				else if(items.get(1).equals("6"))
					about.setText(getContext().getResources().getString(R.string.repeat6Times));
				else if(items.get(1).equals("10"))
					about.setText(getContext().getResources().getString(R.string.repeat10Times));
				else if(items.get(1).equals("Unlimited"))
					about.setText(getContext().getResources().getString(R.string.unlimited));				
				else if(items.get(1).equals("1"))
					about.setText(getContext().getResources().getString(R.string.repeatOnlyOnce));				

				break;
		}//end cases
		
		//return the view of the item
		return view;
	
	}//end of method 'getView'
	
}//EOF

